<template>
	<view id="purchase">
		<view class="top-warp">
			<view v-for="(tab, i) in tabList" :key="i" :class="{'active':curIndex===i}" @click="changeTab(i)">{{tab.category_name}}</view>
		</view>
		
		<swiper class="swiper" :current="curIndex" @change="swiperChange">
			<!--待付款和已付款 -->
			<swiper-item v-for="(item, index) in tabList" :key="index">
				<mescroll-item :i="index" :index="curIndex"></mescroll-item>
			</swiper-item>
		</swiper>
		
	</view>
</template>

<script>
	import MescrollItem from "./mescroll-swiper-item.vue";
	
	export default {
		components: {
			MescrollItem
		},
		data() {
			return {
				// 选项卡列表
				tabList: [{
					category_name: '待付款' 
				}, { 
					category_name: '已付款' 
				}],
				curIndex: 0 // 当前tab的下标
			}
		},
		onLoad() {  
		},
		methods: {
			// 轮播菜单
			swiperChange(e){
				this.changeTab(e.detail.current)
			},
			// 切换菜单
			changeTab(i){
				this.curIndex = i
			}
		}
	}
</script>

<style lang="scss">
	page, #purchase, .swiper{
		height: 100%;
	}
	.top-warp{
		z-index: 9990;
		position: fixed;
		top: --window-top; /* css变量 */
		left: 0;
		width: 100%;
		height: 92upx;
		background-color: #fff;
		text-align: center;
		display: flex;
	}
	.top-warp view{
		line-height: 92upx;
		font-size: 30upx;
		flex: 1;
	}
	.top-warp .active{
		border-bottom: 4upx solid #D8B36B;
		color: #D8B36B;
	}
</style>
